<style>

        .ds1{
                float: left;
        }
        #addt1{
                text-align: center;
        }
        .del1{
                font-size: 13px;
        }
        #edui2 div{
                height: 20px;
        }


        #suggestions{
            background-color: black;
            color: white;
        }

        #autoSuggestionsList{
            background-color: black;
            color: white;
        }
        .suggestionList li {

                margin: 0px 0px 0px 0px;
                padding: 3px;
                cursor: pointer;
        }

        .suggestionList li:hover {
                background-color: #659CD8;

        }

        .all li {
                width:100px;
                height:30px;
                line-height:20px;
                text-align:center;
                float:left;
                display:inline;
                position:relative;
                cursor:pointer;
                left:-40px;
                top:-7px;
        }
        .all ul {
                position:absolute;
                left:0;
                top:30px;
                display:none;
        }
</style>
<script language="JavaScript">



    function lookup(inputString) {
        cus=-1;
        if(inputString.length == 0) {
            // Hide the suggestion box.
            $('#suggestions').hide();
        } else {
            $.post("/admin/command/getplace", {queryString: ""+inputString+""}, function(data){
                if(data.length >0) {
                    $('#suggestions').show();
                    $('#autoSuggestionsList').html(data);
                }
            });
        }
    } // lookup
    function aa (){

        if(document.activeElement.id!="inputString"){

            if(document.activeElement.id!="inputString1"){
                setTimeout("$('#suggestions').hide();", 200);
            }
        }
    }

    function fill(obj) {

        console.log($(obj).html()+"##123123########");
        $('#inputString').val($(obj).html());
        $("#pinfo").html($(obj).attr("pcontent"))
        $("#info_linkid").val($(obj).attr("placeid"))
        $("#info_title").val($(obj).attr("pname"))
        //setTimeout("aa()",200);

    }
    function fill1(thisValue) {
        setTimeout("aa()",200);
    }

    //全局定义 当前选择的li数组下标

    var cus=-1;
    function sitem(event,obj){

//获取所有选项li
        var liarr=$("#autoSuggestionsList").find("li")
        //向上
        if (event.keyCode == 38) {
            $("#inputString1").focus();
            if(-1>cus){
                cus=liarr.length-2;
            }
            cus--;
            $("#autoSuggestionsList").find("li").css("background-color","#252525");
            $(liarr[cus]).css("background-color","#659CD8");
            $("#inputString").val($(liarr[cus]).html())
            $("#inputString1").val($(liarr[cus]).html())
        }

        //向下
        if(event.keyCode == 40){
            $("#inputString1").focus();
            if(cus>liarr.length-2){
                cus=-1;
            }
            cus++;
            $("#autoSuggestionsList").find("li").css("background-color","#252525");
            $(liarr[cus]).css("background-color","#659CD8");
            $("#inputString").val($(liarr[cus]).html())
            $("#inputString1").val($(liarr[cus]).html())
        }
        //回车
        if(event.keyCode == 13){
            console.log($(liarr[cus]).attr("placeid")+"@@@@@@@@");

            $("#inputString").val($(liarr[cus]).html())
            $("#inputString1").val($(liarr[cus]).html())
            $("#pinfo").html($(liarr[cus]).attr("pcontent"))
            $("#info_linkid").val($(liarr[cus]).attr("placeid"))
            $("#info_title").val($(liarr[cus]).attr("pname"))
            $("#inputString").focus();
            cus=-1;
        }
    }

</script>
<div class="content">

    <div id="addinfo" class="addinfo" >
        <form action="" method="post" id="infosub1">
            <input type="hidden" id="infoopid" name="id" value=""/>
            <input type="hidden" name="p_id" value=""/>
            <input type="hidden" id="info_op" name="op" value=""/>
            <input type="hidden" id="info_tr_id" name="tr_id" value=""/>
            <input type="hidden" id="info_itype" name="itype" value=""/>
            <input type="hidden" id="info_tagid" name="tagid" value=""/>
            <input type="hidden" id="info_content" name="info" value=""/>
            <input type="hidden" id="info_linkid" name="linkid" value=""/>
            <input type="hidden" id="info_sort" name="sort" value=""/>
            <input type="hidden" id="info_infotime" name="infotime" value=""/>


            <div id="splace">
                选择景点 <input type="text" size="30" value="" id="inputString" onfocus="lookup(this.value);" onkeyup="lookup(this.value);" onblur="fill1();"  onkeydown="sitem(event,this)" autocomplete="off"/>
                         <input type="hidden" name="place_id" id="place_id" value="">
                <div style="width: 0px; height: 0px; overflow: hidden"><input  type="text" size="30" value="" id="inputString1" onkeydown="sitem(event,this)" onblur="fill1();" autocomplete="off"/></div>

                <div class="suggestionsBox" id="suggestions" style="display: none;">
                    <div class="suggestionList" id="autoSuggestionsList">
                        &nbsp;
                    </div>
                </div>
            </div>
            <input class="input-box"  id="info_title" type="text" name="title" placeholder="内容标题" value="">
            <textarea  name="info" id="info"></textarea>
            <div id="pinfo" style="height: 100px; overflow: auto"></div>
            <input onclick="infosub()" style="width:200px" type="button" class="btn btn-success btn-block" value="确认"/>

        </form>
    </div>
</div>
<script language="javascript" type="text/javascript" src="/assets/My97DatePicker/jquery-1.8.2.js"></script>
<script language="javascript" type="text/javascript" src="/assets/libs/fastadmin-layer/src/layer.js"></script>
<script src="/ueditor/ueditor.config.js"></script>
<script src="/ueditor/ueditor.all.min.js"></script>
<script src="/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
    var title="<?php echo $_REQUEST['infotitle']?>";
    $("#info_title").val(title);

    UE.getEditor('info', {
        theme:"default", //皮肤
        lang:"zh-cn", //语言
        initialFrameWidth:1078,  //初始化编辑器宽度,默认800
        initialFrameHeight:320//  初始化编辑器高度
    });
</script>
<script language="JavaScript">
   //trid,infotitle,itype,tagid

    function infosub(){
        var title=$("#info_title").val();
        var trid="<?php echo $_REQUEST['trid']?>";
        var itype="<?php echo $_REQUEST['itype']?>";
        var tagid="<?php echo $_REQUEST['tagid']?>";
        var linkid=$("#info_linkid").val();
        var info=UE.getEditor('info').getContent();

        if(itype==7&&linkid==""){
            alert("请正确选择景点");
            return;
        }

        $.ajax({
            type:'post',
            dataType:'json',
            url:"/admin/product/route_info_add",
            data:{"title":title,"trid":trid,"itype":itype,"tagid":tagid,"info":info,"linkid":linkid},
            success:function(data){
                if(data==1){
                    window.parent.location.reload();
                }else{
                    layer.alert("信息添加失败");
                }
            }
        })
    }



</script>




